package justbuy.delivery.model;

import org.ironrhino.core.metadata.NaturalId;
import org.ironrhino.core.model.BaseEntity;
import org.ironrhino.core.model.Ordered;

public class Logistics extends BaseEntity implements Ordered {

	private static final long serialVersionUID = 4527280258606761653L;

	@NaturalId
	private String code;

	private String name;

	private int displayOrder;

	private String website;

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getWebsite() {
		return website;
	}

	public void setWebsite(String website) {
		this.website = website;
	}

	public int getDisplayOrder() {
		return displayOrder;
	}

	public void setDisplayOrder(int displayOrder) {
		this.displayOrder = displayOrder;
	}

	public int compareTo(Object object) {
		if (!(object instanceof Ordered))
			return 0;
		Ordered ordered = (Ordered) object;
		if (this.getDisplayOrder() != ordered.getDisplayOrder())
			return this.getDisplayOrder() - ordered.getDisplayOrder();
		return this.toString().compareTo(ordered.toString());
	}

	@Override
	public String toString() {
		return getName();
	}
}
